<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/XGame_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>XGame</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->

<!-- InstanceEndEditable -->
<link type="text/css" rel="stylesheet" href="CSS/css.css" />
</head>

<body>


<div id="container">

<div id="wrapper">

<div id="banner">
<!-- InstanceBeginEditable name="TopLink" -->
<?php
include('lock.php');
$q = "SELECT user_name FROM user where user_ID = '$login_session'";
$result=mysql_query($q);
$data_fetch=mysql_fetch_array($result);
?>
<ul class="topLink">
<li> Welcome, <a href="UserProfile.php"> <?php echo $data_fetch['user_name']; ?> </a> </li>
<li> <a href="Wishlist.php"> Wishlist </a> &nbsp; | &nbsp;<a href="userShoppingCart.php"> Cart </a> </li>
<li> <a href="Logout.php"> Logout </a> </li>
</ul>
<!-- InstanceEndEditable -->

<img src="Assets/XGame.png" alt="XGame" />
</div>

<div id="menu">
<ul class="nav">

<form method="post" action="search_result.php">
<li> <span> <input type="text" placeholder="Search Keyword" name="search" />
&nbsp; <input type="submit" name="Search" value="Search" /> </span>
</li>
</form>
<li> <a href="Home.php"> Home </a> </li>
<li> <a href="ListOfNews.php"> News </a> </li>
<li> <a href="Games.php"> Games </a> </li>
<li> <a href="FAQ.php"> FAQ </a> </li>
<li> <a href="ContactUs.php"> Contact Us </a> </li>
</ul>

</div>

<div id="main">
<!-- InstanceBeginEditable name="Main" -->
<div class="verticalNav">
<h3> User Account </h3>
<ul>
<li> <a href="Wishlist.php"> Your Wishlist </a> </li>
<li> <a href="userShoppingCart.php"> Shopping Cart </a> </li>
<li> <a href="userCheckOutList.php"> Checkout List </a> </li>
<li> <a href="History.php"> History </a> </li>
</ul>
</div>


<div id="iframe">
<h3 align="center"> Confirmation Details </h3>
<br />

<table border="0" class="table" >
<tr align="center">
<th class="tableHeader"> Product ID</th>
<th class="tableHeader"> Product Name </th>
<th class="tableHeader"> Quantity </th>
<th class="tableHeader"> Unit Price </th>
</tr>

<?php
  global $total;
  global $location;
  global $location_id;
  
  $total=$_POST['total'];
  $location_id=$_POST['location'];
  
  $sql="SELECT location_name FROM location WHERE location_ID='$location_id'";
  $q=mysql_query($sql);
  $data_fetch=mysql_fetch_array($q);
  $location_name=$data_fetch['location_name'];
  
  $q=mysql_query("SELECT demo_ID, COUNT(demo_ID) FROM cart WHERE user_ID='$login_session' GROUP BY demo_ID");
  
  while($data=mysql_fetch_array($q))
  {
    $num_demo_id=$data['COUNT(demo_ID)'];
    $demo_id=$data['demo_ID'];
    $ql=mysql_query("SELECT * FROM demo WHERE demo_ID='$demo_id'");
    
    $data_fetch=mysql_fetch_array($ql);
    
      $demo_price=number_format($data_fetch['demo_price'],2);
      $demo_name=$data_fetch['demo_name'];

    
      echo "<tr class='tableContent'>";
      echo "<td class='tableContent' align='center'> $demo_id </td>";
      echo "<td class='tableContent'> &nbsp; $demo_name </td>";
      echo "<td class='tableContent' align='center'> $num_demo_id </td>";
      echo "<td class='tableContent' align='center'> $ $demo_price </td>";
      echo "</tr>";

    
    
    $query=mysql_query("SELECT game_stock FROM stock WHERE location_ID='$location_id' AND game_ID='$demo_id'");
    while($data_query=mysql_fetch_array($query))
    {
      $game_stock=$data_query['game_stock'];
      if($game_stock<$num_demo_id)
      {
        echo"** Not enough stocks for < ". $demo_name ." > in ". $location. " branch. Items will be available in 3 to 5 days. "."<br/>";
        echo"Currently, we have ". $game_stock. " available stocks for < ". $demo_name. " > in ". $location. " branch." ;
        echo"<br/>"."<br/>";
      }
    }
  }
  
  echo "</table>";
  echo "<br /> <br />";
  
   
  if($total == 0)
  {
    echo "<p align='center'> Total Price: $ 0</p>";
  }
  else 
  {
    echo "<p align='center'> Total Price: $ $total</p>";
  }  

  $hour= date("H") + 6;
	if($hour > 23)
	{
	$hour = $hour - 24;
	}
	$order_date = date("Y-m-d $hour:i:s");
	
  echo "<p align='center'> Check-Out-Date: $order_date</p>";
  echo "<p align='center'> Location : $location_name </p>";  
?>

<br />
<p align="center"> Do you still want to proceed? </p>
       
                  
   <table align="center">
   <tr>
   <td>
    <form action="userCheckOutList.php" method="post">
      <input type="hidden" name="total" value="<? echo $total ?>" />
      <input type="hidden" name="order_date" value="<? echo $order_date ?>" />
      <input type="hidden" name="location_id" value="<? echo $location_id ?>" />
      <input type="hidden" name="location_name" value="<? echo $location_name ?>" />
      <input type="submit" onClick="window.location.href=window.location.href" value="Yes"/>  
    </form> 
  </td>
    
  <td>
    <form action="userShoppingCart.php" method="post">
      <input type="submit" onClick="window.location.href=window.location.href" value="No"/>  
    </form>
  </td>
  </tr>
  </table>
  
</div>
<!-- InstanceEndEditable -->
</div>

<div id="footer">
<p align="center"> &copy; &nbsp; 2012 XGame </p>
</div>

</div>

</div>

</body>
<!-- InstanceEnd --></html>
